<?php
// 本类由系统自动生成，仅供测试用途
namespace Admin\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
              
              $m=M('goods');
              $resulta=$m->count();
             $this->assign('count',$resulta);
             
               $n=M('guestbook');   
              $resultb=$n->count();
             $this->assign('comment',$resultb);
             
               $k=M('admin');   
              $resultc=$k->count();
             $this->assign('user',$resultc);
             
               $l=M('option'); 
               $resa=$l->select();
               $this->assign('dat',$resa);
               
              $resb=$l->where("name='news'")->find();
               $resc=$l->where("name='geyan'")->find();
             
              $this->assign('geyan',$resc);
              $this->assign('news',$resb);
             $this->display();
    }
    
    function add(){
       if(IS_POST)
     {    
          $m=M('option');
           $ide['name']=$_POST['newname'];
           $ide['value']=$_POST['newvalue'];
           $count=$m->add($ide);
           if($count>0){
				$this->success('数据增加成功');
			}else{
				$this->error('添加失败');
			}
     }else{
     
     $this->error('非法操作哦！');
     }

    }
   
   	public function set(){
		         if(IS_POST)
     {    
        
                $m=M('option');
                $id1['name']=$_POST['name1'];
                $id2['name']=$_POST['name2'];

                
                $data1['value']=$_POST['value1'];
                $data2['value']=$_POST['value2'];
             
           
                
                $count1=$m->where($id1)->save($data1);
                $count2=$m->where($id2)->save($data2);

                
                $count=$count1+$count2;
                
                if($count>0){
                   $this->error('修改成功了哈哈哈哈哈哈！');
                  }else{
                  $this->error('修改失败啦！');
             }
     }  else{
     
      $this->error('非法操作哦！');
     }
     
   }   
}